﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Xml;
using System.Data.SqlClient;
using System.Text;

public partial class left_bot : System.Web.UI.Page
{
    ArrayList names = new ArrayList();
    private XmlDocument xmlDoc;
    bool isLogin = false;
    protected void Page_Load(object sender, EventArgs e)
    {

        
        if (Session["userinfo"] == null || Session["userinfo"].ToString().Trim() == "")
            isLogin = false;
        else
            isLogin = true;
        if (isLogin)
        {
            this.ImageButton6.ImageUrl = "~/img/后台管理.jpg";
        }
        else
        {
            this.ImageButton6.ImageUrl = "~/img/用户登录.jpg";
        }



        form1.Target = "menu";

        if (Session["userinfo"] == null || Session["userinfo"].ToString().Trim() == "")
            isLogin = false;
        else
            isLogin = true;
    }


    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
        SqlConnection conn = DataBase.getConnection();


        xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath("inc/map.xml"));
        XmlNode xn = xmlDoc.SelectSingleNode("TREENODES");
        string s1, s2, s3;

        ///////////////////////////////////////////////
        XmlElement a = xmlDoc.CreateElement("TREENODE");
        a.SetAttribute("TEXT", "新参保人员列表");
        s1 = HttpUtility.UrlEncode("参保", Encoding.UTF8);
        s2 = HttpUtility.UrlEncode("cbzt", Encoding.UTF8);
        s3 = HttpUtility.UrlEncode("新参保", Encoding.UTF8);
        a.SetAttribute("NavigateURL", s1 + "/list.aspx?order="+s2+"&name="+s3);
        a.SetAttribute("target", "main");
        xn.AppendChild(a);
        //////////

        a = xmlDoc.CreateElement("TREENODE");
        a.SetAttribute("TEXT", "按资金账户分类");
        a.SetAttribute("NavigateURL", "");
        a.SetAttribute("target", "main");
        string sql = "select * from dbo.资金账户表";
        SqlCommand cmd = new SqlCommand(sql, conn);
        if(conn.State == ConnectionState.Closed)
            conn.Open();
        SqlDataReader sdr = cmd.ExecuteReader();


        s2 = HttpUtility.UrlEncode("code", Encoding.UTF8);

        while (sdr.Read())
        {
            XmlElement xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", sdr.GetString(0));
            s3 = HttpUtility.UrlEncode(sdr.GetString(0), Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list.aspx?order=" + s2 + "&name=" + s3);
            xe.SetAttribute("target", "main");
            a.AppendChild(xe);
        }
        xn.AppendChild(a);
        sdr.Close();

        /////

        a = xmlDoc.CreateElement("TREENODE");
        a.SetAttribute("TEXT", "按归属单位");
        a.SetAttribute("NavigateURL", "");
        a.SetAttribute("target", "main");
        sql = "select * from dbo.归属单位表";
        cmd = new SqlCommand(sql, conn);
        sdr = cmd.ExecuteReader();
        s2 = HttpUtility.UrlEncode("归属单位", Encoding.UTF8);

        while (sdr.Read())
        {
            XmlElement xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", sdr.GetString(1));
            s3 = HttpUtility.UrlEncode(sdr.GetString(1), Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list.aspx?order=" + s2 + "&name=" + s3);
            xe.SetAttribute("target", "main");
            a.AppendChild(xe);
        }
        xn.AppendChild(a);
        sdr.Close();
        ////

        

       
        ////
        //if (isLogin)
        {
            a = xmlDoc.CreateElement("TREENODE");
            a.SetAttribute("TEXT", "创建新参保");
            s1 = HttpUtility.UrlEncode("参保", Encoding.UTF8);
            a.SetAttribute("NavigateURL", s1 + "/add.aspx?order=&name=");
            a.SetAttribute("target", "main");
            xn.AppendChild(a);
        }

        ///
        a = xmlDoc.CreateElement("TREENODE");
        a.SetAttribute("TEXT", "打印");
        a.SetAttribute("NavigateURL", "javascript:parent.main.focus();javascript:print()");
        a.SetAttribute("target", "");
        xn.AppendChild(a);
        ////
        if (isLogin)
        {
            xmlDoc.Save(Server.MapPath("inc/map1.xml"));
            Response.Redirect("left.aspx?order=a");
        }
        else
        {
            xmlDoc.Save(Server.MapPath("inc/map1_.xml"));
            Response.Redirect("left_.aspx?order=a");
        }

       
    }
    protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
    {
        

        
    }
    protected void ImageButton3_Click(object sender, ImageClickEventArgs e)
    {
        
        
    }
    protected void ImageButton4_Click(object sender, ImageClickEventArgs e)
    {
        

        
    }
    protected void ImageButton5_Click(object sender, ImageClickEventArgs e)
    {
       
    }
    protected void ImageButton6_Click(object sender, ImageClickEventArgs e)
    {
        xmlDoc = new XmlDocument();
        xmlDoc.Load(Server.MapPath("inc/map.xml"));
        XmlNode xn = xmlDoc.SelectSingleNode("TREENODES");
        string s1, s2, s3;

        ///////////////////////////////////////////////
        //XmlElement a = xmlDoc.CreateElement("TREENODE");
        //a.SetAttribute("TEXT", "后台管理");
        //a.SetAttribute("NavigateURL", "");
        //a.SetAttribute("target", "");
        if (isLogin)
        {
            s1 = HttpUtility.UrlEncode("系统管理", Encoding.UTF8);
            XmlElement xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "参保比例管理");
            xe.SetAttribute("NavigateURL", s1 + "/list_cbbl.aspx?order=&name=");
            xe.SetAttribute("target", "main");
            //a.AppendChild(xe);
            xn.AppendChild(xe);
            //

            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "个人身份管理");
            //s1 = HttpUtility.UrlEncode("系统管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_grsf.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "平均工资管理");
            //s1 = HttpUtility.UrlEncode("平均工资管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_pjgz.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "文化程度管理");
            //s1 = HttpUtility.UrlEncode("平均工资管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_whcd.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "险种管理");
            //s1 = HttpUtility.UrlEncode("平均工资管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_xgxz.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "用工形式管理");
            //s1 = HttpUtility.UrlEncode("平均工资管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_ygxs.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "资金账户管理");
            //s1 = HttpUtility.UrlEncode("平均工资管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/list_zjzh.aspx?order=&name=");
            xe.SetAttribute("target", "main");

            xn.AppendChild(xe);
            //
            xe = xmlDoc.CreateElement("TREENODE");
            xe.SetAttribute("TEXT", "更换用户密码");
            s1 = HttpUtility.UrlEncode("用户管理", Encoding.UTF8);
            xe.SetAttribute("NavigateURL", s1 + "/update.aspx?order=&name=");
            xe.SetAttribute("target", "main");
            xn.AppendChild(xe);
            //


        }
        //////////



        //a = xmlDoc.CreateElement("TREENODE");
        //a.SetAttribute("TEXT", "能源消费时间图");
        //a.SetAttribute("NavigateURL", s1 + "/select1.aspx?order=&name=");
        //a.SetAttribute("target", "main");
        //xn.AppendChild(a);



        if (isLogin)
        {
            xmlDoc.Save(Server.MapPath("inc/map6.xml"));
            Response.Redirect("left.aspx?order=f");
        }
        else
        {
            xmlDoc.Save(Server.MapPath("inc/map6_.xml"));
            //Response.Redirect("left_.aspx?order=f");
            Response.Write("<script language='javascript'>parent.location.href='login.aspx';</script>");
        }
        
    }

    

    
}
